<div class="create-ticket">
<div class="create-ticket-atas">Create Ticket</div>
<div class="create-ticket-tengah">
<div align="right" class="notif">*)  can not be empty</div>
<?php if((isset($_SESSION['sys_admin']))||(isset($_SESSION['admin']))||(isset($_SESSION['intern_audit']))||(isset($_SESSION['second_consult']))||(isset($_SESSION['dept_pic']))) {?>

<style type="text/css">

.urgent {
	background:#FFCCFF;
	}
.critical {
	background:#FE9A2E;
	}
.serious {
	background:#F7FE2E;
	}
.medium {
	background:#74DF00;
	}
.minimum {
	background:#33CC33;
	}
	.cmnt {
		width:auto;
		height:auto;
		padding-top:10px;
		padding-left:5px;
		padding-right:0px;
		padding-bottom:5px;
		border:1px solid #CCCCCC;
		-moz-border-radius:5px;
		}
	.cmnt table tr td {
		border:none;
		}
	.cmnt a {
		color:#FFFFFF;
		}
</style>
<script type="text/javascript">
function add_file_field(){
var container=document.getElementById('file_container');
var file_field=document.createElement('input');
file_field.name='images[]';
file_field.type='file';
container.appendChild(file_field);
var br_field=document.createElement('br');
container.appendChild(br_field);
}

</script>
<?php
if($severity == "Urgent") {
	$target_date = " 1 day";
	$cl ="urgent";
} else if($severity == "Critical") {
	$target_date = " 2 day";
	$cl="critical";
} else if($severity == "Serious") {
	$target_date = "5 day";
	$cl="serious";
} else if($severity == "Medium"){
	$target_date = "7 day";
	$cl="medium";
} else if($severity == "Minimum"){
	$target_date = "9 day";
	$cl="minimum";
} else {
	$target_date ="";
	$cl ="";
}
?>
<?php
if($change == $ticket_id) {
	$a = "";
}else {
	$a ="disabled";
}
?>

<h2><?php echo $h2_title;?></h2>
<?php
echo ! empty($message) ? '<p class="message">' . $message . '</p>': '';

	$flashmessage = $this->session->flashdata('message');
	echo ! empty($flashmessage) ? '<p class="message">' . $flashmessage . '</p>': '';
?>

<form action="<?php echo $form_action;?>" method="post" name="kirim" enctype="multipart/form-data">
<table>
	<tr>
    	<td>ID</td><td>:</td><td>
        
        <input type="text" name="" disabled="disabled" value="<?php echo $id;?>" />
         <input type="hidden" name="ticket_id" value="<?php echo $id;?>" />
		</td><td></td><td></td>
    </tr>
    <tr>
    	<td>Title<font class="notif">*</font></td><td>:</td><td><input type="text" name="title"  value="<?php echo $title;?>"/></td><td></td><td><?php echo form_error('title', '<i class="field_error">', '</i>');?></td>
    </tr>
   
    <tr>
    	<td>Probability<font class="notif">*</font></td><td>:</td><td>
        	
        	<select name="prob_o_impact" class="fg" id="prob_o_impact">
            	<option value=""></option>
            	<option value="3" class="opt1" <?php if($prob == "3") echo "selected";?> ><span>Difficult</span></option>
                <option value="4" class="opt2" <?php if($prob == "4") echo "selected";?>>Medium</option>
                <option value="5" class="opt3" <?php if($prob == "5") echo "selected";?>>Easy</option>                
            </select>
        </td><td></td><td><?php echo form_error('prob_o_impact', '<i class="field_error">', '</i>');?></td>
    </tr>
     <tr>
    	<td>Level<font class="notif">*</font></td><td>:</td><td>
        	<select name="level_o_impact" id="level_o_impact"  class="fg">
            	<option value=""></option>
            	<option value="5" class="opt1" <?php if($level == "5") echo "selected";?> ><span>Critical</span></option>
                <option value="4" class="opt2" <?php if($level == "4") echo "selected";?>>High</option>
                <option value="3" class="opt3" <?php if($level == "3") echo "selected";?>>Medium</option>
                <option value="2" class="opt4" <?php if($level == "2") echo "selected";?>>Low</option>
				<option value="1" class="opt5" <?php if($level == "1") echo "selected";?>>Very Low</option>
            </select>
        </td><td></td><td><?php echo form_error('level_o_impact', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Severity Level<font class="notif">*</font></td><td>:</td><td>
		
		<input type="text" name="severity_level" readonly="" value="<?php echo $severity;?>" class="cb" id="severity" />
        	
        </td><td></td><td><?php echo form_error('severity_level', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Target Date<font class="notif">*</font></td><td>:</td><td>
		<select name="target_date" class="fg"  id="target">
			<option value="" ></option>
			<option value="1 day" >1 day</option>
			<option value="2 day" >2 day</option>
			<option value="5 day" >5 day</option>
			<option value="7 day" >7 day</option>
			<option value="9 day" >9 day</option>
		</select>
		&nbsp;<a href="Javascript:openWindow('<?php echo site_url('createticket/ticket/coments');?>')"><img src="<?php echo base_url();?>images/12.png" alt="Tambah Data" width="16" height="16" align="absmiddle" border="0" /> &nbsp;Cange Target Date</a></td><td></td><td><?php echo form_error('target_date', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Reference ID</td><td>:</td><td><input type="text" name="reference_id"  value="<?php if(isset($ref)) {echo $ref;} else {};?>"  />
        	&nbsp;&nbsp;<a href="Javascript:openWindowRef('<?php echo site_url('createticket/ticket/search_reference/'.$id_user);?>')"><img src="<?php echo base_url();?>images/11.png" alt="Search Reference Id" width="16" height="16" align="absmiddle" border="0" /> &nbsp;Search</a>

        </td><td></td><td></td>
    </tr>
     <tr>
    	<td>Open Datetime<font class="notif">*</font></td><td>:</td><td><input type="text" name="open_date" disabled="disabled" value="<?php echo date('d-m-Y H:i:s');?>"/>
        <input type="hidden" name="open_datetime" value="<?php echo date('d-m-Y H:i');?>"/> 

        </td><td></td><td><?php echo form_error('open_datetime', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Close Date Time</td><td>:</td><td><input type="text" name="close_date" disabled="disabled" />
        	<input type="hidden" name="close_date" value="" />
        </td><td></td><td></td>
    </tr>
     <tr>
    	<td>Product<font class="notif">*</font></td><td>:</td><td>
        	<select name="prod_id" class="fg">
            	<option value=""></option>
            	<?php foreach($prod->result() as $prod) :?>
            	<option value="<?php echo $prod->prod_id;?>" <?php if($product == $prod->prod_id) echo "selected";?>><?php echo $prod->product;?></option>
                <?php endforeach;?>

                
            </select>
        </td><td></td><td><?php echo form_error('prod_id', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>User<font class="notif">*</font></td><td>:</td><td><input type="text" name="user_id2" disabled="disabled" value="<?php echo $name;?>" />
        <input type="hidden" name="user_id"  value="<?php echo $id_user;?>" />
        <input type="hidden" name="user_id2" value="<?php echo $name;?>" />
        </td><td></td><td><?php echo form_error('user_id', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Status</td><td>:</td><td><input type="text" name="status" disabled="disabled" value="Open" />
        	<input type="hidden" name="status" value="Open"  />
        </td><td></td><td></td>
    </tr>
    <tr>
    	<td>Vulnerability Detail<font class="notif">*</font></td><td>:</td><td>
        </td><td></td>
    </tr>
    
    <tr>
    	<td></td><td>:</td><td><textarea name="vul_detail" rows="20" class="tinymce"><?php echo $vul_det;?></textarea></td><td></td><td><?php echo form_error('vul_detail', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Impact<font class="notif">*</font></td><td>:</td><td>
        </td><td></td>
    </tr>
    	<td></td><td></td><td><textarea name="impact_detail" rows="20" class="tinymce"><?php echo $impact;?></textarea></td><td></td><td><?php echo form_error('impact_detail', '<i class="field_error">', '</i>');?></td>
    </tr>
	<tr>
    	<td>Vulnerability Solution<font class="notif">*</font></td><td>:</td><td>
        </td><td></td>
    </tr>
    <tr>
    	<td></td><td></td><td><textarea name="sol_detail" rows="20" class="tinymce"><?php echo $vul_sol;?></textarea></td><td></td><td><?php echo form_error('sol_detail', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
	
   
</table>
<div class="cmnt">
<table>
    <tr>
    	<td>Coments</td><td>:</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td></td><td>
		<input type="hidden" name="tanggal" value="<?php echo date('d-m-Y H:i');?>"/>
		<input type="hidden" name="id" value="<?php echo $idcmnt2;?>" />
		<textarea name="notes" cols="25" rows="20" class="tinymce"><?php echo $coments;?></textarea>
        </td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td>Create Image</td><td>:</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td></td><td><div id="file_container">
    <input name="images[]" type="file" value="Choose"  /><br />
    
  </div><a href="javascript:void(0);" onClick="add_file_field();">Add another</a>
</td><td></td><td></td>
    </tr>
    
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
</table>
</div>
   <div class="notif">*)  can not be empty</div>
<div class="form-reg-submit"><input type="submit" class="ok" value="" name="create" />&nbsp;&nbsp;<input type="reset" value="" class="no" /></div>
</form>
<script language="javascript">
$('#prob_o_impact').change(function(){
	/*$.post("<?php //echo base_url();?>index.php/createticket/ticket/get_value/"+$('#prob_o_impact').val(),{data1:$('#prob_o_impact').val()},
		function(o){
			$('#severity').html(o);
		}
	);*/
	calc_sev();
	if($('#severity').val() =='Minimum') {
		$('#target').val('9 day');

	}else if($('#severity').val() =='Medium') {
		$('#target').val('7 day');
	}else if($('#severity').val() =='Serious') {
		$('#target').val('5 day');
	}else if($('#severity').val() =='Critical') {
		$('#target').val('2 day');
	}else if($('#severity').val() =='Urgent') {
		$('#target').val('1 day');
	}
	 else {
		$('#target').val('');
	}
	
});
$('#level_o_impact').change(function(){
 	calc_sev();
	if($('#severity').val() =='Minimum') {
		$('#target').val('9 day');

	}else if($('#severity').val() =='Medium') {
		$('#target').val('7 day');
	}else if($('#severity').val() =='Serious') {
		$('#target').val('5 day');
	}else if($('#severity').val() =='Critical') {
		$('#target').val('2 day');
	}else if($('#severity').val() =='Urgent') {
		$('#target').val('1 day');
	}
	 else {
		$('#target').val('');
	}
});


function calc_sev(){
	/*$('#severity').val($('#prob_o_impact').val() * $('#level_o_impact').val());*/
	if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==3) {	
		$('#severity').val('Minimum');
		$('.cb').css("background-color","#3366CC");
	
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==4) {
		$('#severity').val('Medium');
		$('.cb').css("background-color","#74DF00");
	
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==5) {
		$('#severity').val('Medium');
		$('.cb').css("background-color","#74DF00");
		
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==6) {
		$('#severity').val('Medium');
		$('.cb').css("background-color","#74DF00");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==8) {
		$('#severity').val('Serious');
		$('.cb').css("background-color","#F7FE2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==9) {
		$('#severity').val('Serious');
		$('.cb').css("background-color","#F7FE2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==10) {
		$('#severity').val('Serious');
		$('.cb').css("background-color","#F7FE2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==12) {
		$('#severity').val('Serious');
		$('.cb').css("background-color","#F7FE2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==15) {
		$('#severity').val('Critical');
		$('.cb').css("background-color","#FE9A2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==16) {
		$('#severity').val('Critical');
		$('.cb').css("background-color","#FE9A2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==20) {
		$('#severity').val('Critical');
		$('.cb').css("background-color","#FE9A2E");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==25) {
		$('#severity').val('Urgent');
		$('.cb').css("background-color","#FF3300");
	}
}
/*function target_date() {
	if($('#severity').val('Note')) {
		$('#target').val('9 day');
	}else if($('#severity').val('Low')) {
		$('#target').val('7 day');
	}else if($('#severity').val('Medium')) {
		$('#target').val('5 day');
	}else if($('#severity').val('High')) {
		$('#target').val('2 day');
	}else if($('#severity').val('Critical')) {
		$('#target').val('1 day');
	}
}*/

</script>
<?php } ?>
</div>
<div class="create-ticket-bawah"></div>
</div>